package com.dtx.day06.staticProxy;

import com.dtx.day06.order.OrderDao;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

public class OrderDaoProxy implements OrderDao {

    private OrderDao orderDao;

    public OrderDaoProxy(OrderDao orderDao) {
        this.orderDao = orderDao;
    }

    @Override
    public List<Map<String, Object>> findOrderByUser(String userName) {
        // 获取当前系统时间，获取方法名，获取参数
        StringBuilder sb = new StringBuilder();
        sb.append("执行时间"+ LocalDateTime.now())
        .append(",执行的方法 findOrderByUser")
        .append("，传入的参数是userName="+userName);
        List<Map<String, Object>> list = orderDao.findOrderByUser(userName);
        sb.append("返回结果"+list);
        System.out.println(sb);
        return list;
    }

    @Override
    public boolean removeOrderById(String orderNum) {
        // 获取当前系统时间，获取方法名，获取参数
        StringBuilder sb = new StringBuilder();
        sb.append("执行时间"+ LocalDateTime.now())
                .append(",执行的方法 findOrderByUser")
                .append("，传入的参数是orderNum="+orderNum);
        boolean f = orderDao.removeOrderById(orderNum);
        sb.append("返回结果"+f);
        System.out.println(sb);
        return f;
    }
}
